package org.imlinker.communiaction;

public class CommandDecoder implements InterfaceCommandDecoder {
	private String message;
	private InterfaceSafeBox safeBox;
	private boolean legal = true;
	
	public CommandDecoder(String message, InterfaceSafeBox safeBox) {
		this.message = message;
		this.safeBox = safeBox;
		legal = safeBox.checkThePassword(getPassword());
	}
	
	public String[] getMessageArray() {
		return this.message.split("[|]");
	}
	
	public String getCommand() {
		return getMessageArray() [2];
	}

	public String getID() {
		return getMessageArray() [1];
	}

	public String getMessage() {
		return message;
	}

	public String getPluginName() {
		return getMessageArray() [0];
	}

	public void sendMessageBack() {
		if (islegal()) {
			//To do list;
		}
	}

	public String getPassword() {
		return getMessageArray() [3];
	}

	public boolean islegal() {
		return legal;
	}
}
